<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订单列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>桌位号：</label>
                            <input type="text" name="deskNum"/>
                        </li>
                        <li>
                            <label>订单金额：</label>
                            <input type="text" name="money"/>
                        </li>
                        <li>
                            <label>实付金额：</label>
                            <input type="text" name="payMoney"/>
                        </li>
                        <li>
                            <label>用餐人数：</label>
                            <input type="text" name="useMunber"/>
                        </li>
                        <li>
                            <label>订单状态：</label>
                            <select name="state" th:with="type=${@dict.getType('rest_order_state')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="rest:order:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="rest:order:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('rest:order:edit')}]];
    var removeFlag = [[${@permission.hasPermi('rest:order:remove')}]];
    var stateDatas = [[${@dict.getType('rest_order_state')}]];
    var prefix = ctx + "rest/order";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            settlementUrl: prefix + "/settlement/{id}",
            modalName: "订单",
            columns: [{
                checkbox: false
            },
                {
                    field: 'orderNo',
                    title: '订单号',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="" href="javascript:void(0)" onclick="$.modal.openTab(\'订单详情' + row.orderNo + '\',\'' + prefix + '/info/' + row.orderNo + '\',false)">' + row.orderNo + '</a> ');
                        return actions.join('');
                    }
                },
                {
                    field: 'deskNum',
                    title: '桌位号',
                    formatter: function (value, row, index) {
                        return value + "号桌";
                    }
                },
                {
                    field: 'money',
                    title: '订单金额'
                },
                {
                    field: 'payMoney',
                    title: '实付金额'
                },
                {
                    field: 'useMunber',
                    title: '用餐人数'
                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    field: 'state',
                    title: '订单状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(stateDatas, value);
                    }
                },
                {
                    field: 'createTime',
                    title: '下单时间'
                },
                {
                    field: 'createBy',
                    title: '下单人'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (row.state < 401) {
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.orderNo + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-primary btn-xs  ' + removeFlag + '" href="javascript:void(0)" onclick="$.modal.openTab(\'订单结帐\',\'' + prefix + '/settlement/' + row.orderNo + '\')"><i class="glyphicon glyphicon-saved"></i>结算</a>');
                        }
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>